﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace safehomeSimulation
{
    public partial class frmGenerateE : Form
    {
        private Room _room1;
        private Room _room2;
        private Room _room3;
        private Room _room4;

        private coreSys _core = new coreSys();

        public frmGenerateE()
        {
            InitializeComponent();
        }

        public frmGenerateE(ref Room room1, ref  Room room2, ref Room room3, ref Room room4)
        {
            InitializeComponent();
            _room1 = room1;
            _room2 = room2;
            _room4 = room4;
            _room3 = room3;
        }


        private void btnGenerate_Click(object sender, EventArgs e)
        {
            Random random = new Random();

            _room1.Environment(random.Next(0, 120), random.Next(10, 50), random.Next(1, 30), random.Next(5, 50));
            _room1.CaptureEnvironment();
            List<Msg> msgsOfRoom1 = _room1.GetAllMsg();

            _core.ProcessMsg(msgsOfRoom1);

            List<Msg> msgs1 = _core.GetCoreAllMsg();
            if (msgs1 != null)
            {
                frmResponse response = new frmResponse(ref msgs1);
                response.ResponseTOMsg(msgs1);
                response.Show();
            }

            _room2.Environment(random.Next(0, 120), random.Next(10, 50), random.Next(1, 30), random.Next(5, 50));
            _room2.CaptureEnvironment();
            List<Msg> msgsOfRoom2 = _room2.GetAllMsg();

            _core.ProcessMsg(msgsOfRoom2);

            List<Msg> msgs2 = _core.GetCoreAllMsg();
            if (msgs2 != null)
            {
                frmResponse response = new frmResponse(ref msgs2);
                response.ResponseTOMsg(msgs2);
                response.Show();
            }


            _room3.Environment(random.Next(0, 120), random.Next(10, 50), random.Next(1, 30), random.Next(5, 50));
            _room3.CaptureEnvironment();
            List<Msg> msgsOfRoom3 = _room3.GetAllMsg();

            _core.ProcessMsg(msgsOfRoom3);

            List<Msg> msgs3 = _core.GetCoreAllMsg();
            if (msgs3 != null)
            {
                frmResponse response = new frmResponse(ref msgs3);
                response.ResponseTOMsg(msgs3);
                response.Show();
            }


            _room4.Environment(random.Next(0, 120), random.Next(10, 50), random.Next(1, 30), random.Next(5, 50));
            _room4.CaptureEnvironment();
            List<Msg> msgsOfRoom4 = _room4.GetAllMsg();

            _core.ProcessMsg(msgsOfRoom4);

            List<Msg> msgs4 = _core.GetCoreAllMsg();
            if (msgs4 != null)
            {
                frmResponse response = new frmResponse(ref msgs4);
                response.ResponseTOMsg(msgs4);
                response.Show();
            }


        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
